<?php


namespace api\modules\app\models;
use Yii;

class QrcodeTag extends \yii\db\ActiveRecord
{
    const TAG_CODE_UNIT = 1;
    const TAG_CODE_LOCATION = 2;

    public static function getTagCodeList() {
        return [
            self::TAG_CODE_UNIT => '部件',
            self::TAG_CODE_LOCATION => '点位',
        ];
    }

    public static function getTagCodeByKey($key) {
        $result = '';
        $list = self::getTagCodeList();
        if (array_key_exists($key, $list)) {
            $result = $list[$key];
        }
        return $result;
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'qrcode_tag';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('test_3');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['qrcode', 'tag_code', 'tag_name','is_delete','create_time','update_time'], 'safe'],
        ];
    }
}